package com.gin.retrofit.interceptor

import okhttp3.Interceptor
import okhttp3.Response

/**
 * 临时日志拦截器
 * @author bx002
 * @since 2024/2/18 11:57
 */
class LogInterceptor : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val t0 = System.currentTimeMillis()
        val request = chain.request()
        println("[DEBUG] 请求开始 URL: ${request.url}")
        val response = chain.proceed(request)
        val t1 = System.currentTimeMillis()
        println("[DEBUG] 请求结束 URL: ${request.url} 耗时: ${t1 - t0} 毫秒")
        return response
    }
}